import 'package:flutter/material.dart';

class TopTabListPage extends StatefulWidget {
  final int count;

  TopTabListPage(this.count);

  @override
  State<StatefulWidget> createState() => new _TopTabListPageState();
}

class _TopTabListPageState extends State<TopTabListPage> {
  @override
  Widget build(BuildContext context) {
    if (widget.count > 0) {
      return new ListView.builder(
        itemCount: widget.count,
        itemBuilder: (BuildContext context, int index) {
          return _createListItem(index + 1);
        },
      );
    } else {
      return new Center(
        child: new Text("查询不到记录"),
      );
    }
  }

  Widget _createListItem(int index) {
    return new Card(
      margin: EdgeInsets.only(top: 5.0),
      child: new Container(
        padding: EdgeInsets.all(10.0),
        child: new ListTile(
          subtitle: new Column(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: <Widget>[
              new Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: <Widget>[
                  new Text(
                    "标题" + index.toString(),
                    style: new TextStyle(
                      fontWeight: FontWeight.bold,
                      fontSize: 16.0,
                    ),
                  ),
                ],
              ),
              new Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: <Widget>[
                  new Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: <Widget>[
                      new Text("时间："),
                      new Text("2018-08-01 11:22:33"),
                    ],
                  ),
                ],
              ),
              new Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: <Widget>[
                  new Container(
                    padding: EdgeInsets.symmetric(vertical: 10.0),
                    child: new Text("内容："),
                  ),
                ],
              ),
            ],
          ),
        ),
      ),
    );
  }
}

TextStyle _itemTextStyle =
    new TextStyle(fontWeight: FontWeight.normal, fontSize: 14.0);
